﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TemplatePatterns
{
    public abstract class TemplateSorting<T> where T : IComparable
    {
        #region Template pattern

        /// <summary>
        /// Template method - bubble sorting
        /// </summary>
        /// <param name="mass"></param>
        public void Sort(ref T[] mass)
        {
            for (int i = 0; i < mass.Length - 1; i++)
            {
                for (int j = i + 1; j < mass.Length; j++)
                {
                    Swap(ref mass[i], ref mass[j]);
                }
            }
        }

        protected abstract void Swap(ref T itemA, ref T itemB);

        #endregion
    }
}
